import "./index.css";
import {View,Image} from "@tarojs/components";
import {AtButton} from "taro-ui";
import Footer from '../../components/Footer';
import images from '../../assets/img.png';
import  reslutList from '../../data/reslut.json';
import questionList from '../../data/question.json';
import Taro from "@tarojs/taro";
import getBestQuestionResult from '../../utils/rankUtils'

export default () => {
  // const reslut =reslutList[0]
  var answerLsit = Taro.getStorageSync('answerLsit')
  if (!answerLsit || answerLsit.length < 1){
    Taro.showToast({
      title: '失败',
      icon: 'error',
      duration: 2000
    })
  }
 const reslut  = getBestQuestionResult(answerLsit,questionList,reslutList)
  return (
    <View className='result'>
      <View className='at-article__h1 titele1'>
        {reslut.resultName}
      </View>
      <View className='at-article__h1 titele2'>
        {reslut.resultDesc}
      </View>
      <AtButton type='primary' className='startbut' circle={true}  onClick={() => {
        Taro.reLaunch({
          url: '/pages/index/index',
        })
      }}
      >返回主页</AtButton>
      <Image
        src={images}
        className='imgPage'
      />
      <Footer/>
    </View>
  );
};
